package com.systop.scos.diary.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;

import com.systop.common.modules.security.user.model.User;
import com.systop.core.model.BaseModel;
import com.systop.scos.diary.diaryType.model.DiaryType;

/**
 * 工作日志表
 */
@SuppressWarnings("serial")
@Entity
@Table(name = "diarys")
public class Diary extends BaseModel {

	/** 主键 */
	private Integer id;

	/** 标题 */
	private String title;

	/** 内容 */
	private String content;

	/** 作者 */
	private User user;

	/** 时间 */
	private Date createDate;

	/** 最后修改时间 */
	private Date endDate;

	/** 日志类别 */
	private DiaryType diaryType;

	/** 构造方法 */
	public Diary() {
	}

	/** 构造方法 */
	public Diary(Integer id) {
		this.id = id;
	}

	@Id
	@GeneratedValue(generator = "hibseq")
	@GenericGenerator(name = "hibseq", strategy = "hilo")
	@Column(name = "id", nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@Column(name = "content")
	@Type(type = "text")
	public String getContent() {
		return this.content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	@Column(name = "Create_Date")
	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	@Column(name = "end_date")
	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumn(name = "type_id")
	public DiaryType getDiaryType() {
		return diaryType;
	}

	public void setDiaryType(DiaryType diaryType) {
		this.diaryType = diaryType;
	}

	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumn(name = "user_id")
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}
}
